package Views;

import Controllers.ScheduleController;
import Models.Car;
import Models.Employee;
import Models.Route;
import Models.Schedule;
import java.awt.event.WindowEvent;
import javax.swing.event.ListSelectionEvent;

public class SchedulePanel extends ViewAbstract<Schedule>
{
	private Employee chosenEmployee;
	private Route chosenRoute;
	private Car chosenCar;

	public SchedulePanel(SearchableTabbedPane parent)
	{
        initComponents();
		this.controller = new ScheduleController();
		this.tabbedPane = parent;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Sep2 = new javax.swing.JSeparator();
        showAllB = new javax.swing.JButton();
        Sep3 = new javax.swing.JSeparator();
        newB = new javax.swing.JButton();
        editB = new javax.swing.JButton();
        deleteB = new javax.swing.JButton();
        cancelB = new javax.swing.JButton();
        saveB = new javax.swing.JButton();
        employeeTF = new javax.swing.JTextField();
        searchTF = new javax.swing.JTextField();
        searchB = new javax.swing.JButton();
        Sep1 = new javax.swing.JSeparator();
        chooseEmployeeB = new javax.swing.JButton();
        showEmployeeB = new javax.swing.JButton();
        routeNoTF = new javax.swing.JTextField();
        chooseRouteB = new javax.swing.JButton();
        showRouteB = new javax.swing.JButton();
        carTF = new javax.swing.JTextField();
        chooseCarB = new javax.swing.JButton();
        showCarB = new javax.swing.JButton();
        dateTF = new javax.swing.JTextField();
        dateL = new javax.swing.JLabel();
        employeeL = new javax.swing.JLabel();
        routeL = new javax.swing.JLabel();
        carL = new javax.swing.JLabel();

        setMaximumSize(new java.awt.Dimension(600, 420));
        setMinimumSize(new java.awt.Dimension(600, 420));
        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(600, 420));

        Sep2.setName("Sep2"); // NOI18N

        showAllB.setText("Vis Alle");
        showAllB.setName("showAllB"); // NOI18N
        showAllB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showAllBActionPerformed(evt);
            }
        });

        Sep3.setOrientation(javax.swing.SwingConstants.VERTICAL);
        Sep3.setName("Sep3"); // NOI18N
        Sep3.setPreferredSize(new java.awt.Dimension(5, 23));

        newB.setText("Ny");
        newB.setName("newB"); // NOI18N
        newB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newBActionPerformed(evt);
            }
        });

        editB.setText("Rediger");
        editB.setEnabled(false);
        editB.setName("editB"); // NOI18N
        editB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editBActionPerformed(evt);
            }
        });

        deleteB.setText("Slet");
        deleteB.setEnabled(false);
        deleteB.setName("deleteB"); // NOI18N
        deleteB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteBActionPerformed(evt);
            }
        });

        cancelB.setText("Annullér");
        cancelB.setEnabled(false);
        cancelB.setName("cancelB"); // NOI18N
        cancelB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelBActionPerformed(evt);
            }
        });

        saveB.setText("Gem");
        saveB.setEnabled(false);
        saveB.setName("saveB"); // NOI18N
        saveB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveBActionPerformed(evt);
            }
        });

        employeeTF.setEnabled(false);
        employeeTF.setMaximumSize(new java.awt.Dimension(200, 200));
        employeeTF.setMinimumSize(new java.awt.Dimension(200, 200));
        employeeTF.setName("employeeTF"); // NOI18N
        employeeTF.setPreferredSize(new java.awt.Dimension(200, 20));

        searchTF.setMaximumSize(new java.awt.Dimension(200, 20));
        searchTF.setMinimumSize(new java.awt.Dimension(200, 20));
        searchTF.setName("searchTF"); // NOI18N
        searchTF.setPreferredSize(new java.awt.Dimension(200, 20));

        searchB.setText("Søg");
        searchB.setName("searchB"); // NOI18N
        searchB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchBActionPerformed(evt);
            }
        });

        Sep1.setName("Sep1"); // NOI18N

        chooseEmployeeB.setText("Vælg");
        chooseEmployeeB.setEnabled(false);
        chooseEmployeeB.setName("chooseEmployeeB"); // NOI18N
        chooseEmployeeB.setNextFocusableComponent(chooseRouteB);
        chooseEmployeeB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chooseEmployeeBActionPerformed(evt);
            }
        });

        showEmployeeB.setText("Vis");
        showEmployeeB.setEnabled(false);
        showEmployeeB.setName("showEmployeeB"); // NOI18N
        showEmployeeB.setNextFocusableComponent(showRouteB);
        showEmployeeB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showEmployeeBActionPerformed(evt);
            }
        });

        routeNoTF.setEnabled(false);
        routeNoTF.setMaximumSize(new java.awt.Dimension(200, 200));
        routeNoTF.setMinimumSize(new java.awt.Dimension(200, 200));
        routeNoTF.setName("routeNoTF"); // NOI18N
        routeNoTF.setPreferredSize(new java.awt.Dimension(200, 20));

        chooseRouteB.setText("Vælg");
        chooseRouteB.setEnabled(false);
        chooseRouteB.setName("chooseRouteB"); // NOI18N
        chooseRouteB.setNextFocusableComponent(chooseCarB);
        chooseRouteB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chooseRouteBActionPerformed(evt);
            }
        });

        showRouteB.setText("Vis");
        showRouteB.setEnabled(false);
        showRouteB.setName("showRouteB"); // NOI18N
        showRouteB.setNextFocusableComponent(showCarB);
        showRouteB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showRouteBActionPerformed(evt);
            }
        });

        carTF.setEnabled(false);
        carTF.setMaximumSize(new java.awt.Dimension(200, 200));
        carTF.setMinimumSize(new java.awt.Dimension(200, 200));
        carTF.setName("carTF"); // NOI18N
        carTF.setPreferredSize(new java.awt.Dimension(200, 20));

        chooseCarB.setText("Vælg");
        chooseCarB.setEnabled(false);
        chooseCarB.setName("chooseCarB"); // NOI18N
        chooseCarB.setNextFocusableComponent(chooseEmployeeB);
        chooseCarB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chooseCarBActionPerformed(evt);
            }
        });

        showCarB.setText("Vis");
        showCarB.setEnabled(false);
        showCarB.setName("showCarB"); // NOI18N
        showCarB.setNextFocusableComponent(showEmployeeB);
        showCarB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showCarBActionPerformed(evt);
            }
        });

        dateTF.setEnabled(false);
        dateTF.setName("dateTF"); // NOI18N

        dateL.setText("Dato:");
        dateL.setName("dateL"); // NOI18N

        employeeL.setText("Vagt:");
        employeeL.setName("employeeL"); // NOI18N

        routeL.setText("Rute:");
        routeL.setName("routeL"); // NOI18N

        carL.setText("Bil:");
        carL.setName("carL"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Sep2, javax.swing.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(showAllB)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(Sep3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(newB)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(editB)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(deleteB)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 187, Short.MAX_VALUE)
                                .addComponent(cancelB)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(saveB))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(employeeL)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(employeeTF, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(chooseEmployeeB)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(showEmployeeB))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(routeL)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(routeNoTF, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(chooseRouteB)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(showRouteB)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(Sep1, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(searchTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(searchB)))))
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(carL)
                        .addGap(18, 18, 18)
                        .addComponent(carTF, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(chooseCarB)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(showCarB)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(dateL)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dateTF, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(409, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(employeeTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchB)
                    .addComponent(searchTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(chooseEmployeeB)
                    .addComponent(showEmployeeB)
                    .addComponent(employeeL))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Sep1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(routeNoTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(chooseRouteB)
                        .addComponent(showRouteB)
                        .addComponent(routeL)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(carL)
                    .addComponent(carTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(chooseCarB)
                    .addComponent(showCarB))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dateTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dateL))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 258, Short.MAX_VALUE)
                .addComponent(Sep2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(showAllB)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(saveB)
                        .addComponent(cancelB)
                        .addComponent(newB)
                        .addComponent(editB)
                        .addComponent(deleteB))
                    .addComponent(Sep3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

	private void showAllBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showAllBActionPerformed
		tabbedPane.search(TabIndex.Schedules, "*");
}//GEN-LAST:event_showAllBActionPerformed

	private void newBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newBActionPerformed
		clearComponents();
		changeComponentState(true);
		newOne = new Schedule();
		newB.setEnabled(false);
		editB.setEnabled(false);
}//GEN-LAST:event_newBActionPerformed

	private void editBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editBActionPerformed
		changeComponentState(true);
		newB.setEnabled(false);
		editB.setEnabled(false);
}//GEN-LAST:event_editBActionPerformed

	private void deleteBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteBActionPerformed
		if(confirmDeletion("vagtplanen")) {
			controller.delete(chosenOne.getScheduleNo());
			clearComponents();
		}
}//GEN-LAST:event_deleteBActionPerformed

	private void cancelBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBActionPerformed
		clearComponents();
		changeComponentState(false);
}//GEN-LAST:event_cancelBActionPerformed

	private void saveBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBActionPerformed
		Schedule theOne = getTheOne();

		try
		{
			theOne.setData(dateTF.getText(), chosenEmployee, chosenRoute, chosenCar);

			if(chosenOne == null) {
				controller.insert(theOne);
			} else {
				controller.update(theOne, "scheduleNo = "+theOne.getScheduleNo());
			}
		}
		catch (Models.EmptyValueException e)
		{
			informAboutEmptyFields();
			return;
		}

		informSavingWentOk("Vagtplanen");
		clearComponents();
		changeComponentState(false);
		newB.setEnabled(true);
}//GEN-LAST:event_saveBActionPerformed

	private void searchBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchBActionPerformed
		tabbedPane.search(TabIndex.Schedules, searchTF.getText());
}//GEN-LAST:event_searchBActionPerformed

	private void chooseEmployeeBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseEmployeeBActionPerformed
		if(picker == null)
		{
			picker = createPicker(TabIndex.Employees);
			picker.addWindowListener(this);
			picker.setVisible(true);
		}
	}//GEN-LAST:event_chooseEmployeeBActionPerformed

	private void showEmployeeBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showEmployeeBActionPerformed
		tabbedPane.switchTabWithNo(TabIndex.Employees, chosenEmployee.getEmployeeNo());
	}//GEN-LAST:event_showEmployeeBActionPerformed

	private void chooseRouteBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseRouteBActionPerformed
		if(picker == null)
		{
			picker = createPicker(TabIndex.Routes);
			picker.addWindowListener(this);
			picker.setVisible(true);
		}
	}//GEN-LAST:event_chooseRouteBActionPerformed

	private void showRouteBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showRouteBActionPerformed
		tabbedPane.switchTabWithNo(TabIndex.Routes, chosenRoute.getRouteNo());
	}//GEN-LAST:event_showRouteBActionPerformed

	private void chooseCarBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseCarBActionPerformed
		if(picker == null)
		{
			picker = createPicker(TabIndex.Cars);
			picker.addWindowListener(this);
			picker.setVisible(true);
		}
	}//GEN-LAST:event_chooseCarBActionPerformed

	private void showCarBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showCarBActionPerformed
		tabbedPane.switchTabWithNo(TabIndex.Cars, chosenCar.getCarNo());
	}//GEN-LAST:event_showCarBActionPerformed

	protected void changeComponentState(boolean state)
	{
		chooseEmployeeB.setEnabled(state);
		showEmployeeB.setEnabled(chosenEmployee != null);
		chooseRouteB.setEnabled(state);
		showRouteB.setEnabled(chosenRoute != null);
		chooseCarB.setEnabled(state);
		showCarB.setEnabled(chosenCar != null);
		dateTF.setEnabled(state);
		cancelB.setEnabled(state);
		saveB.setEnabled(state);
		setUnsavedState(state);
	}

	protected void populateFields()
	{
		this.setChosenEmployee(chosenOne.getEmployee());
		showEmployeeB.setEnabled(chosenEmployee != null);
		this.setChosenRoute(chosenOne.getRoute());
		showRouteB.setEnabled(chosenRoute != null);
		this.setChosenCar(chosenOne.getCar());
		showCarB.setEnabled(chosenCar != null);
		dateTF.setText(chosenOne.getDateToString(false));
		newB.setEnabled(true);
		editB.setEnabled(true);
		deleteB.setEnabled(true);
	}

	protected void clearComponents()
	{
		chosenOne = null;
		newOne = null;
		this.setChosenEmployee(null);
		showEmployeeB.setEnabled(false);
		this.setChosenRoute(null);
		showRouteB.setEnabled(false);
		this.setChosenCar(null);
		showCarB.setEnabled(false);
		dateTF.setText("");
		newB.setEnabled(true);
		editB.setEnabled(false);
		deleteB.setEnabled(false);
	}
	
	protected void showNo(int no)
	{
		chosenOne = controller.find(no);
		populateFields();
	}

	public void valueChanged(ListSelectionEvent e)
	{}

	public void windowClosing(WindowEvent e)
	{
		if(picker != null)
		{
			DB.RowInterface theOne = picker.getTheChosenOne();

			if(theOne != null)
			{
				if(theOne instanceof Employee)
				{
					this.setChosenEmployee((Employee)theOne);
				}
				else if(theOne instanceof Route)
				{
					this.setChosenRoute((Route)theOne);
				}
				else if(theOne instanceof Car)
				{
					this.setChosenCar((Car)theOne);
				}
			}
			
			this.releasePicker();
		}
	}

	public void setChosenCar(Car chosenCar)
	{
		this.chosenCar = chosenCar;
		if(chosenCar != null)
		{
			carTF.setText(String.valueOf(chosenCar.getLicensePlate()));
			showCarB.setEnabled(true);
		}
		else
		{
			carTF.setText("");
			showCarB.setEnabled(false);
		}
	}

	public void setChosenEmployee(Employee chosenEmployee)
	{
		this.chosenEmployee = chosenEmployee;
		if(chosenEmployee != null)
		{
			employeeTF.setText(chosenEmployee.getName());
			showEmployeeB.setEnabled(true);
		}
		else
		{
			employeeTF.setText("");
			showEmployeeB.setEnabled(false);
		}
	}

	public void setChosenRoute(Route chosenRoute)
	{
		this.chosenRoute = chosenRoute;
		if(chosenRoute != null)
		{
			routeNoTF.setText(String.valueOf(chosenRoute.getRouteNo()));
			showRouteB.setEnabled(true);
		}
		else
		{
			routeNoTF.setText("");
			showRouteB.setEnabled(false);
		}
	}

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JSeparator Sep1;
    private javax.swing.JSeparator Sep2;
    private javax.swing.JSeparator Sep3;
    private javax.swing.JButton cancelB;
    private javax.swing.JLabel carL;
    private javax.swing.JTextField carTF;
    private javax.swing.JButton chooseCarB;
    private javax.swing.JButton chooseEmployeeB;
    private javax.swing.JButton chooseRouteB;
    private javax.swing.JLabel dateL;
    private javax.swing.JTextField dateTF;
    private javax.swing.JButton deleteB;
    private javax.swing.JButton editB;
    private javax.swing.JLabel employeeL;
    private javax.swing.JTextField employeeTF;
    private javax.swing.JButton newB;
    private javax.swing.JLabel routeL;
    private javax.swing.JTextField routeNoTF;
    private javax.swing.JButton saveB;
    private javax.swing.JButton searchB;
    private javax.swing.JTextField searchTF;
    private javax.swing.JButton showAllB;
    private javax.swing.JButton showCarB;
    private javax.swing.JButton showEmployeeB;
    private javax.swing.JButton showRouteB;
    // End of variables declaration//GEN-END:variables
}